package com.xiuxiu.manage.back_manage.controller;

import com.xiuxiu.manage.back_manage.entity.Admin;
import com.xiuxiu.manage.back_manage.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class LoginController {

    @Autowired
    private AdminService adminService;

    @RequestMapping(value = "/com",name ="进入登录页面" )
    public String toLogin(){
        return "login";
    }



    @ResponseBody
    @RequestMapping(value = "/verifyLogin",name = "登录验证", method = RequestMethod.POST)
    public String verifyLogin(String username, String password) {
        Admin admin = adminService.adminlogin(username);
        if (admin == null) {
            return "用户不存在";
        }
        if (admin.getPassword().equals(password)) {

                    return "success";

        }
        return "密码错误";
    }

//    @RequestMapping(value ="listnav")
//    public String listNav(){
//        return ;
//    }
}